class Factory {
    private final Map<String, FruitCommand> commands = new HashMap<>();

    public Factory() {
        // 注册命令
        commands.put("A", new CreateAppleCommand());
        commands.put("B", new CreateBananaCommand());
    }

    public Fruit CreateFruit(String kind) {
        FruitCommand command = commands.get(kind);
        if (command != null) {
            return command.execute();
        }
        return null;
    }
}